# report.py
#
# Exercise 3.1
# 
# 请将第二课的代码结果复制到这里，继续练习
# 


# report.py
import csv


def read_portfolio(filename):
    '''
    Read a stock portfolio file into a list of dictionaries with keys
    name, shares, and price.
    '''
    with open(filename, 'r') as f:
        rows = csv.reader(f)
        header = next(rows)
        portfolio = []
        for row in rows:
            record = {
                'name': row[0],
                'shares': int(row[1]),
                'price': float(row[2])
            }
            portfolio.append(record)
        return portfolio


output = read_portfolio('Playground/Data/portfolio.csv')
print(output)